home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr22 / fcheck10.zip / REPEAT.DOC < prev    next >
Text File  |  1992-12-02  |  7KB  |  168 lines

  1.                                   REPEAT v2.2
  2.  
  3.  
  4.                             (c) 1992 by Ben Bernard
  5.  
  6.  
  7. Intro:
  8.   The original idea of REPEAT was to allow you to apply a single command to
  9. multiple files.  This is needed for such commands as TYPE, which don't
  10. accept wildcards.  The solution was REPEAT TYPE # FOR *.TXT, where # was
  11. replaced by each successive file processed.
  12.   In using v 1.0 I found many other things which I thought should be added.
  13. You can see the result below.  Macro substitutions allow REPEAT to perform
  14. complex decisions based on variables related to the files being processed.
  15. New to version 2.1 is a wildcard matching routine which increases flexibility
  16. and a subdirectory recursion option, along with new macros and operators.
  17.   REPEAT is really a prototype, written with MS BASIC PDS 7.1, of a future
  18. program to be implemented in C when I get time to do so.  In the meantime,
  19. if I have left what you deem to be a useful feature out of REPEAT, drop me
  20. a line at the adresses listed at the end.
  21.  
  22. Legal stuff: 
  23.           You use this program AT YOUR OWN RISK.  By using REPEAT, you
  24.  agree to absolve me of all claims for damage to any hardware, software, or
  25.  data which might be caused by this program.  You are hereby granted license to
  26.  use REPEAT for any use and any period of time, provided you do not modify the
  27.  code in any way.  This software may be distributed only in its original and
  28.  complete package, either in the original ZIP file or in an equivalent archive.
  29.  No fee can be charged for this software.  Disk duplicators and BBSs may,
  30.  however, charge a fee for their services.  While registration of this
  31.  software is not required, donations are appreciated.
  32.  
  33.  
  34. Usage:  REPEAT {command} FOR {filespec} IF {mask}
  35.   {command} will be executed once for each file in {filespec} for which
  36.   {mask} evaluates to true.
  37. {command} can contain any DOS command, plus the macros listed below.
  38. {filespec} can have full pathname and more.
  39. {mask} is optional and can contain any of the macros and operators below.
  40. Macros:                     Operators:
  41.   $bd   space on drive d       {       }    =     ~
  42.   $d    file drive             greater less equal match
  43.   $e    extension              @  &   !
  44.   $f    filename               or and not
  45.   $n    basename
  46.   $p[x] full path (0=no end \ 1=no drive 2=from spec 3=last level)
  47.   $s    file size
  48.   $t    file time
  49.   $y    file date
  50.   $[  ] left justify macros between [ ]
  51.   $r  ] right justify macros between r ]
  52.   $c  ] center macros between c ]
  53.   $()   pass as a literal the text between ()
  54.   $$    $
  55.   $_    new line (allows multiple commands)
  56.   $,    <  \
  57.   $.    >   }these must be used to delay DOS redirection
  58.   $\    |  /
  59.  
  60.  
  61.  
  62. Some details:
  63.  
  64. As I mentioned in the v2.0 docs, the directory is no longer preloaded.  This
  65.   was changed to allow traversing of directory trees.
  66.  
  67. To use DOS redirection within {command} you must use the $, $. and $\ macros.
  68.  
  69. You may now use the $() macro to pass macros literally, thus making it
  70.   possible to have REPEAT call itself recursively (probably not a good idea).
  71.  
  72. Paths MUST end with '\' or '/'.  If you use D:\TEST as the filespec, REPEAT
  73.   will interpret D:\ as the path and TEST as the filespec.  If you use D:\TEST\
  74.   REPEAT will interpret D:\TEST\ as the path and *.* as the filespec.
  75.  
  76. Multiple filespecs can be included in {filespec} by separating them with commas.
  77.  
  78. Any path ending with '/' will cause REPEAT to recurse through all of its
  79.   subdirectories.  Paths ending in '\' will not be recursed.
  80.  
  81. Filespec matching is done by REPEAT, and not by DOS.  This means, among other
  82.   things, that *P* will match only files with a P in their name, and not all
  83.   files.  It also means that a name is a name, and extensions, including the
  84.   '.' are treated as part of the name.  *.* is still a legitimate spec, but
  85.   will match the same as '*' because all files, extension or not, have the '.'.
  86.  
  87. The path macro works as follows:
  88.   Assume the directory structure C:\DOS\DOC
  89.   REPEAT echo $p $p0 $p1 $p2 $p3 for c:/.   will produce the following output:
  90.  
  91.   C:\DOS\ C:\DOS \DOS DOS DOS
  92.   C:\DOS\DOC\ C:\DOS\DOC \DOS\DOC DOS\DOC DOC
  93.  
  94.   NOTE that because root directories have no '.' entry, they are not processed
  95.   by 'for "/."'
  96.  
  97. Directories are not normally processed by REPEAT.  However, you can tell
  98.   REPEAT to process directory entries using the . and .. filespecs.  These
  99.   are not exactly like the DOS equivalents.  The . filespec tells REPEAT
  100.   to execute the commands once for each directory recursed.  The .. filespec
  101.   tells REPEAT to process the commands once for each directory entry.  The
  102.   DOS . and .. directory entries are _never_ processed.
  103.  
  104. The disk space macro ($b) can accept the file drive macro ($d) as a parameter.
  105.  
  106. The justification macros ($[ $r $c) pack as many spaces in as there are
  107.   characters between the macro and the terminator (exclusive).  The space
  108.   between can contain other macros, EXCEPT other justification macros and
  109.   the new line macro.
  110.  
  111. The equal operator '=' does a straight, no wildcards, comparison.  To use
  112.   wildcards, use the match operator '~'.
  113.  
  114. The new line macro allows multiple shelled commands per line.  Each $_ causes
  115.   the command up to that point to be executed in a shell.
  116.  
  117. The comparison operators treat dates specially so that they will be handled
  118.   properly.
  119.  
  120. Pressing <ESC> during execution will result in REPEAT pausing when it regains
  121.   control, at which time you can decide to abort REPEAT or continue.
  122.  
  123. Nothing in REPEAT is case sensitive.
  124.  
  125.  
  126. Examples:
  127.  
  128.  repeat echo $[$f          ]  $r$s       ]  $y  $t for *.* if $y=10-11-1990
  129.    Produces a DOS-like directory of all files with date 10-11-1990.
  130.  
  131.  repeat copy $f a:\ for *.* if $ba}$s
  132.    Copies files from current directory to drive a as long as there is space
  133.    for them.  Note that the disk space check is done dynamically, so that
  134.    as each file is copied onto drive a, the space available is adjusted
  135.    accordingly.
  136.  
  137.  repeat del $n.obj for *.bas
  138.    Deletes .OBJ files with same basename as existing .BAS files.
  139.  
  140.  repeat copy $d:$p1\$f c:\$d$f for d:/*.* e:/*.* f:/*.* if $bc>$s
  141.    Copies all files from d, e, and f to their respective directories
  142.    in c, as long as there is space on c for the file.  Note that the
  143.    directories must exist already.
  144.  
  145.  repeat md c:\$p2 for d:/. e:/. f:/.
  146.    Creates on C the directory structures of D, E, and F.
  147.  
  148. History:
  149.  
  150. 12-02-1992  2.2     Added path options 0-3, changed recursion order,
  151.                     allow use of . and .. for directory operations,
  152.                     added $_ for newline.
  153. 01-01-1992  2.1     Added wildcard matching, recursion, and some macros.
  154.                     Changed to dynamic method of reading directories.
  155. 12-20-1991  2.0     Replaced EXCEPT with IF, added macros and operators.
  156. ?           1.1     Added the except clause.
  157. ?           1.0     Original version of REPEAT, never release to the public.
  158.  
  159.  
  160. Suggestions, donations, feedback, or just plain comments can be addressed to:
  161.  
  162. InterNet:    ben.bernard@channel1.com
  163. RIME:        R/O Ben Bernard ->CHANNEL
  164. SnailMail:   Ben Bernard
  165.              709 E 17th St
  166.              Houston, TX 77008
  167.  
  168.